// pages/user/login/password-recovery/password-recovery.js
import Notify from "@vant/weapp/notify/notify";
import Toast from "@vant/weapp/toast/toast";
import {verifyInput, verifyPhone} from "../../../../utils/Util"
Page({

    /**
     * 页面的初始数据
     */
    data: {
        formData: {

        },
        stepOneShow: false,
        btnLoading: false
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /*
    * input输入
    * */
    onInputChange: function (e) {
        console.log(e)
        let name = e.currentTarget.dataset.name;
        this.data.formData[name] = e.detail
    },

    /*
    * 内容提交
    * */
    onSubmit: function () {
        try {
            const that = this;
            let formData = that.data.formData;
            if (!verifyInput(formData.type)) {
                Notify({message: "请选择客户类型"});
                return false
            } else if (!verifyInput(formData.phone)) {
                Notify({message: "手机号码不能为空"});
                return false
            } else if (!verifyPhone(formData.phone)) {
                Notify({message: "手机号码格式不正确"});
                return false
            } else if (!verifyInput(formData.verify)) {
                Notify({message: "短信验证码不能为空"});
                return false
            } else if (that.data.btnLoading) {
                return false
            } else {
                that.setData({btnLoading: true});
                Toast({
                    type: "success",
                    message: "登录成功",
                    onClose: () => {
                        console.log('执行OnClose函数');
                    }
                });
            }
        } catch (e) {
            console.log(e)
        }
    }
})